Right.
Now, let's add some code so that when somebody presses this button, we're going to get the UI and
we're going to get a message saying, Hey, you could join the bottle or not.
So let's make this UI invisible because we only want to show it when there's a battle being initiated.
I'm going to go back down to screen Gooey Battle Royale frame and then I'll just make that visible unchecked.
Now let's scroll up to the workspace.
Open it here.
We're going to look for our bottle wall.
There it is by the wall.
And I have an initiate battle script.
Let's bring that over.
Let's open that up.
All right.
We're going to need a few variables.
We'll get a variable for replicated storage local.
I'll just call it R's replicated storage game, get service, replicated storage.
And remember, in replicated storage, we have our battle, Ari.
Let's see.
Let's call this battle Ari Replicated storage.
Wait for child Battle royale.
Ari, close enough for our variable.
All right.
We're going to need a queue time.
How long do we want to keep it open?
How long do we want to keep the queue open?
Let's do queue.
Time equals 15, and then we want to have a flag.
If the queues initiated, we don't want to re initiate a queue.
We only want one queue at a time.
So I say is initiated, I will say false.
We'll start that out.
It's false.
You know what else we're going to need?
We're going to need a sound.
I'll just put a variable here for the sound.
Let's make it nil for now.
Let's go find the sound, though.
All right.
So let's go back to our zombie world real quick.
We'll go to the toolbox and in Marketplace took audio and the sound that I had in the demo.
I kind of like that.
I don't like to look around for stuff like that, like sounds.
I'm going to do a public underscore.
I think I call that places.
There it is.
This is the one.
I kind of like that.
I'm going to put that in my bottle wall.
Go ahead and insert.
Now because I didn't put that on a part.
It's going to reverberate throughout the entire entire game, right?
So if you put it on a part, you're going to get that sound roll off.
If you just put it under a model, you're not going to get the sound roll off.
And that's what I want.
I want everybody on this whole and this whole workspace to be able to hear it so they can accept the
battle if they want to fight.
So let's go back to our script, initiate battle script, and we can go ahead and put that sound in
there.
We have our script parent and then we could rename it.
I'm not going to, though.
I'm just going to do this.
Public Places Announcement Tone Reverberate 004.
That's all right.
We're going to use the we're going to use the variable that I have S and D.
Let's go down to start registration now.
This fire is off when we hit the click detector, the little green button on the bottle wall.
I'm going to check to see if a battle is initiated already.
So if not is initiated, then we can go ahead and initiate a bottle.
We don't want to initiate a battle if there is already one initiated.
So let's go to format, format, document.
There we go.
So as soon as we get in this, if statement, we're going to say is initiated is now true and once we
send, all of our players will say initiated equals false.
Now we're going to do a few more things.
Like one, we've got to play our announcement.
So we have our sound colon play and we can insert our players in there.
You know what?
Let's go ahead and just comment this out for now.
And then because we want to put the players in if they accept.
And this is just for one player anyway, the person who started the registration.
And I'm not going to make it so that if you start the registration, you have to be in the battle.
You just hit the button, you get it going, you still have to accept.
So you could still not be in the battle if you wanted to be.
I thought that would be the best way.
All right.
So I got my bottle, Ari.
And then what I'm going to do is fire all clients.
That's going to send a message to everybody's UI in the game, everybody's player in the game.
So I don't have to put a player in here, but I am going to send the queue time.
Then I'm going to go down here and I will wait the queue time.
Also for now I'm going to comment out, send players.
I want to try this out in studio.
And if you'll recall, the teleport service set it right.
The Teleport Service does not work in studio.
You have to do that in when you're playing your game.
On the roadblocks player.
Now let's capture this remote event on the client side so we can bring up our UI.
What I'm going to do is I'm going to go up here and I'm going to copy these two lines.
Right click copy.
And I go down to my.
Starter.
C Starter.
Gooey.
Screen Gooey.
Battle Royale Frame.
I'll go ahead and put the script right on the frame.
Remember, we want a local script.
There we go.
And let's call this.
Battle local.
How about that battle royale?
Luke All right, now we have that print statement.
Let's go ahead and do a control V.
I'll make this a little bigger so you could see it.
First thing we want to do is pop up that.
Pop up that window.
Right.
Local.
I'll do Battle Ephrem and we'll do a script.
Dot Parent.
That's the battle frame.
And I'll do this.
What is it?
Battle RC is a remote event.
That's it.
Battle Re on client event Connect function.
Remember we're going to get the queue time.
It's like 15 seconds or something and then I'll get my battle frame Visible equals true.
All right.
And then I'm going to do a for loop.
I'm going to do for I.
I'm going to go in reverse order.
So I'm going to go I equals the queue time, which is 15 will go down to zero in steps of negative one.
And then we have our battle label, right?
The the label.
I need a variable for that.
So we need to go let's do that battle label.
So it's on the battle frame.
We got that and then we're going to go down one level Battle Royale label.
That's it.
We'll get our battle label.
And then we had the text on the bottle label.
That's what we're going to change.
And we'll say something like Battle.
I'll just make it short.
Battle in dot, dot, dot.
We'll do a string concatenate, which is two dots, and then we'll put the I, and then you can put
like seconds if you want.
But you're going to see the countdown right o and make sure the countdown is one second by doing a weight.
All right.
That's pretty cool.
Let's go ahead and try this out.
I'm going to play the game.
Hit the play button.
And there we go.
You blew your streak.
I've not been very good at my street.
Oh, what happened?
There we go.
See our our kills death leaderboards a little bit in a way that decline.
You can hit the tab button to make it go away.
We might want to make that a little smaller.
And of course, these don't do anything yet, but that's pretty cool.
We should make this we should make this go away at the end of the 15 seconds.
Let's do that.
Hit the stop.
And we'll go to Battle Royale.
Luke.
And then at the end we will say battle frame dot visible equals false.